home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94b.txt / 000062_icon-group-sender _Tue Sep 20 15:30:41 1994.msg < prev    next >
Internet Message Format  |  1995-02-09  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 20 Sep 1994 15:46:32 MST
  2. From: Nevin Liber <nevin@caslon>
  3. Message-Id: <199409202230.PAA03229@caslon.CS.Arizona.EDU>
  4. Subject: Re: Question: conjunction in Icon and C
  5. To: eschen@molbio.cbs.umn.edu (Art Eschenlauer)
  6. Date: Tue, 20 Sep 1994 15:30:41 -0700 (MST)
  7. Cc: icon-group@cs.arizona.edu
  8. In-Reply-To: <9409202041.AA18914@molbio.cbs.umn.edu> from "Art Eschenlauer" at Sep 20, 94 03:41:27 pm
  9. X-Mailer: ELM [version 2.4 PL23]
  10. Content-Type: text
  11. Content-Length: 1024      
  12. Errors-To: icon-group-errors@cs.arizona.edu
  13.  
  14. Art Eschenlauer proudly drove the following message along the Information SuperHypeway(TM) at breakneck speeds:
  15.  
  16. > In Icon, if I say:
  17. > if <expr1> & <expr2> then <expr3> else <expr4>
  18. > and <expr1> fails, <expr2> will not be evaluated.
  19. > In C, if I say:
  20. > if ( <expr1> && <expr2> ) <expr3>; else <expr4>;
  21. > and <expr1> has a value of zero (NULL, etc.), is it defined (in the ANSI 
  22. > standard, I guess) whether <expr2> will be evaluated or is this compiler 
  23. > specific?
  24.  
  25. In C, if <expr1> has a value of 0, then <expr2> is not evaluated, and
  26. the value of the expression ( <expr1> && <expr2> ) is 0.  If <expr1>
  27. has a non-zero (true) value, then <expr2> is evaluated, and the value
  28. of the expression ( <expr1> && <expr2> ) is 0 if <expr2> is 0,
  29. otherwise, the value is 1 (unlike Icon, where you might expect it to be
  30. the same as <expr2>).  This is specified in both K&R 1 as well as the
  31. ANSI C standard.
  32. -- 
  33.     Nevin ":-)" Liber    nevin@cs.arizona.edu    (602) 293-2799
  34.                                                   ^^^ (520) after 3/95
  35.